import { setStorage } from './storage'

export const setDefaultLang = (lang) => {
    if(lang) {
        // todo
    } else {
        let params = new URLSearchParams(location.search)
        lang = params.get('localeLang')
        if(!lang) {
            lang = localStorage.getItem('localeLang')
        }
        if(!lang) {
            let language = window?.navigator?.language?.toLowerCase()
            if(language.includes('zh')) {
                lang =  'zh-CN'
            } else {
                lang = 'en-US'
            }
        }
    }
    setStorage('localeLang', lang)
    return lang
}
